package org.stratusdb.error;

/**
 * Enumeration for error and messages
 * @author cbinnig
 *
 */
public enum EnumError {
	NO_ERROR,
	MYSQL_ERROR,
	COMPUTE_ERROR,
	COMPUTE_CMD_INVALID;
	
	public static String toString(EnumError error, String[] args){
		String msg = "";
		
		switch(error){
		case NO_ERROR:
			msg =  "No error occured!";
			break;
		case MYSQL_ERROR:
			msg =  "MySQL error: \"<arg0>\"";
			break;
		case COMPUTE_ERROR:
			msg =  "Compute error: \"<arg0>\"";
			break;
		case COMPUTE_CMD_INVALID:
			msg =  "Compute cmd not valid: \"<arg0>\"";
			break;
		}
		
		//replace args
		if(args!=null){
			for(int i=0; i<args.length; ++i){
				msg = msg.replaceAll("<arg"+i+">", args[i]);
			}
		}
		
		return msg;
	}
}
